home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / swanson / frmole.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-01-06  |  9.2 KB  |  283 lines

  1. VERSION 2.00
  2. Begin Form frmOLE 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "OLE Automation"
  5.    ClientHeight    =   4725
  6.    ClientLeft      =   1095
  7.    ClientTop       =   1485
  8.    ClientWidth     =   6555
  9.    ClipControls    =   0   'False
  10.    Height          =   5130
  11.    Left            =   1035
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4725
  14.    ScaleWidth      =   6555
  15.    Top             =   1140
  16.    Width           =   6675
  17.    Begin Frame Frame4 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "Object Info"
  20.       ClipControls    =   0   'False
  21.       Height          =   2010
  22.       Left            =   4545
  23.       TabIndex        =   17
  24.       Top             =   105
  25.       Width           =   1935
  26.       Begin CommandButton cmdLoadExcel 
  27.          Caption         =   "Show Excel"
  28.          Enabled         =   0   'False
  29.          Height          =   375
  30.          Index           =   4
  31.          Left            =   120
  32.          TabIndex        =   10
  33.          Top             =   930
  34.          Width           =   1700
  35.       End
  36.       Begin CommandButton cmdLoadExcel 
  37.          Caption         =   "Is Excel Running?"
  38.          Height          =   375
  39.          Index           =   3
  40.          Left            =   120
  41.          TabIndex        =   9
  42.          Top             =   405
  43.          Width           =   1700
  44.       End
  45.    End
  46.    Begin Frame Frame2 
  47.       BackColor       =   &H00C0C0C0&
  48.       Caption         =   "In Place Activation"
  49.       ClipControls    =   0   'False
  50.       Height          =   2310
  51.       Left            =   105
  52.       TabIndex        =   15
  53.       Top             =   2295
  54.       Width           =   6360
  55.       Begin Frame Frame3 
  56.          BackColor       =   &H00C0C0C0&
  57.          Caption         =   "MemStorage"
  58.          Height          =   975
  59.          Left            =   120
  60.          TabIndex        =   5
  61.          Top             =   1155
  62.          Width           =   1665
  63.          Begin OptionButton optMem 
  64.             BackColor       =   &H00C0C0C0&
  65.             Caption         =   "Disk"
  66.             Height          =   270
  67.             Index           =   1
  68.             Left            =   150
  69.             TabIndex        =   7
  70.             Top             =   630
  71.             Width           =   1215
  72.          End
  73.          Begin OptionButton optMem 
  74.             BackColor       =   &H00C0C0C0&
  75.             Caption         =   "RAM"
  76.             Height          =   270
  77.             Index           =   0
  78.             Left            =   150
  79.             TabIndex        =   6
  80.             Top             =   330
  81.             Value           =   -1  'True
  82.             Width           =   1215
  83.          End
  84.       End
  85.       Begin CommandButton cmdOLE2 
  86.          Caption         =   "Activate"
  87.          Height          =   375
  88.          Left            =   120
  89.          TabIndex        =   4
  90.          Top             =   570
  91.          Width           =   1710
  92.       End
  93.       Begin OLE OLE1 
  94.          BorderStyle     =   0  'None
  95.          Class           =   "Excel.Sheet.5"
  96.          fFFHk           =   -1  'True
  97.          Height          =   1575
  98.          Left            =   2760
  99.          OleObjectBlob   =   FRMOLE.FRX:0000
  100.          SizeMode        =   1  'Stretch
  101.          TabIndex        =   8
  102.          Top             =   570
  103.          Width           =   3420
  104.       End
  105.       Begin Label lblResult 
  106.          AutoSize        =   -1  'True
  107.          BackStyle       =   0  'Transparent
  108.          Caption         =   "00.00 - sec."
  109.          FontBold        =   -1  'True
  110.          FontItalic      =   0   'False
  111.          FontName        =   "MS Sans Serif"
  112.          FontSize        =   9.75
  113.          FontStrikethru  =   0   'False
  114.          FontUnderline   =   0   'False
  115.          ForeColor       =   &H00800000&
  116.          Height          =   240
  117.          Index           =   3
  118.          Left            =   4095
  119.          TabIndex        =   16
  120.          Top             =   240
  121.          Width           =   1185
  122.       End
  123.    End
  124.    Begin Frame Frame1 
  125.       BackColor       =   &H00C0C0C0&
  126.       Caption         =   "OLE Automation"
  127.       ClipControls    =   0   'False
  128.       Height          =   2010
  129.       Left            =   105
  130.       TabIndex        =   11
  131.       Top             =   105
  132.       Width           =   4320
  133.       Begin CheckBox chkVisible 
  134.          BackColor       =   &H00C0C0C0&
  135.          Caption         =   "Visible"
  136.          Height          =   495
  137.          Left            =   1980
  138.          TabIndex        =   1
  139.          Top             =   330
  140.          Width           =   900
  141.       End
  142.       Begin CommandButton cmdLoadExcel 
  143.          Caption         =   "Close Object"
  144.          Height          =   375
  145.          Index           =   2
  146.          Left            =   120
  147.          TabIndex        =   3
  148.          Top             =   1480
  149.          Width           =   1710
  150.       End
  151.       Begin CommandButton cmdLoadExcel 
  152.          Caption         =   "Shell"
  153.          Height          =   375
  154.          Index           =   1
  155.          Left            =   120
  156.          TabIndex        =   2
  157.          Top             =   930
  158.          Width           =   1710
  159.       End
  160.       Begin CommandButton cmdLoadExcel 
  161.          Caption         =   "CreateObject"
  162.          Height          =   375
  163.          Index           =   0
  164.          Left            =   120
  165.          TabIndex        =   0
  166.          Top             =   405
  167.          Width           =   1710
  168.       End
  169.       Begin Label lblResult 
  170.          AutoSize        =   -1  'True
  171.          BackStyle       =   0  'Transparent
  172.          Caption         =   "00.00 - sec."
  173.          FontBold        =   -1  'True
  174.          FontItalic      =   0   'False
  175.          FontName        =   "MS Sans Serif"
  176.          FontSize        =   9.75
  177.          FontStrikethru  =   0   'False
  178.          FontUnderline   =   0   'False
  179.          ForeColor       =   &H00800000&
  180.          Height          =   240
  181.          Index           =   2
  182.          Left            =   3000
  183.          TabIndex        =   12
  184.          Top             =   1500
  185.          Width           =   1185
  186.       End
  187.       Begin Label lblResult 
  188.          AutoSize        =   -1  'True
  189.          BackStyle       =   0  'Transparent
  190.          Caption         =   "00.00 - sec."
  191.          FontBold        =   -1  'True
  192.          FontItalic      =   0   'False
  193.          FontName        =   "MS Sans Serif"
  194.          FontSize        =   9.75
  195.          FontStrikethru  =   0   'False
  196.          FontUnderline   =   0   'False
  197.          ForeColor       =   &H00800000&
  198.          Height          =   240
  199.          Index           =   1
  200.          Left            =   3000
  201.          TabIndex        =   13
  202.          Top             =   1005
  203.          Width           =   1185
  204.       End
  205.       Begin Label lblResult 
  206.          AutoSize        =   -1  'True
  207.          BackStyle       =   0  'Transparent
  208.          Caption         =   "00.00 - sec."
  209.          FontBold        =   -1  'True
  210.          FontItalic      =   0   'False
  211.          FontName        =   "MS Sans Serif"
  212.          FontSize        =   9.75
  213.          FontStrikethru  =   0   'False
  214.          FontUnderline   =   0   'False
  215.          ForeColor       =   &H00800000&
  216.          Height          =   240
  217.          Index           =   0
  218.          Left            =   3000
  219.          TabIndex        =   14
  220.          Top             =   510
  221.          Width           =   1185
  222.       End
  223.    End
  224. Dim xlSheet As Object
  225. Dim ixlHwnd As Integer
  226. Dim lMsgRslt As Long
  227. Sub cmdLoadExcel_Click (Index As Integer)
  228.   Select Case Index
  229.     Case 0  ' Create Object
  230.       Screen.MousePointer = 11
  231.       Start = Timer
  232.         Set xlSheet = CreateObject("Excel.Sheet")
  233.         DoEvents
  234.         
  235.         If chkVisible.Value Then
  236.           xlSheet.Application.Visible = True
  237.         End If
  238.         
  239.       Finish = Timer
  240.       Screen.MousePointer = 0
  241.       lblResult(Index) = Format$(Finish - Start, "##.##") & " secs."
  242.     Case 1  ' Shell Excel
  243.       Screen.MousePointer = 11
  244.       Start = Timer
  245.         iRetVal% = Shell("EXCEL.EXE", 1)  ' Minimized without focus.
  246.         DoEvents
  247.       Finish = Timer
  248.       Screen.MousePointer = 0
  249.       lblResult(Index) = Format$(Finish - Start, "##.##") & " secs."
  250.     Case 2  ' Close Objects
  251.       On Error Resume Next
  252.       
  253.       If xlSheet.Application.Visible Then
  254.         xlSheet.Application.Quit
  255.       Else
  256.         Set xlSheet = Nothing
  257.       End If
  258.     Case 3  ' Is Excel Running
  259.       ixlHwnd = FindWindow("XLMAIN", 0&)
  260.       If ixlHwnd <> 0 Then
  261.         cmdLoadExcel(4).Enabled = True
  262.         MsgBox "Excel is running.  It's handle is " & Str$(ixlHwnd), 64, "Excel Status"
  263.       Else
  264.         cmdLoadExcel(4).Enabled = False
  265.         MsgBox "Excel is NOT running.", 64, "Excel Status"
  266.       End If
  267.     Case 4  ' Show Excel
  268.       lMsgRslt = SendMessage(ixlHwnd, WM_SYSCOMMAND, SC_RESTORE, 0)
  269.   End Select
  270. End Sub
  271. Sub cmdOLE2_Click ()
  272.   If optMem(0).Value Then
  273.     OLE1.MiscFlags = 1
  274.   Else
  275.     OLE1.MiscFlags = 0
  276.   End If
  277.   Start = Timer
  278.     OLE1.Action = 7   'Activate the object
  279.     ' DoEvents
  280.   Finish = Timer
  281.   lblResult(3) = Format$(Finish - Start, "##.##") & " secs."
  282. End Sub
  283.